<form id="add-blocuri-form" request="<?php echo url_for($form->request) ?>" action="javascript:void(0)" autocomplete="off">
    <?php if ($form->isCSRFProtected()) echo $form[$form->getCSRFFieldName()]->render(); ?>

    <div class="header">
        <?php if (!isset($header)): ?>
            Enumeraţi blocurile şi scările care fac parte din Asociaţie:
        <?php else: ?>
            <?php echo $header; ?>
        <?php endif; ?>
    </div>

    <table>
        <thead>
            <tr>
                <td class="label">Bloc</td>
                <td class="label">Scările componente</td>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($form[EmptyBlocListForm::WRAPPER_NAME] as $list): ?>
                <tr class="bloc">
                    <td>
                        <?php echo $list['name']->render(array('class' => 'bloc')); ?>
                    </td>
                    <td>
                        <?php foreach ($list[EmptyBlocForm::WRAPPER_NAME] as $scara): ?>
                            <div class="scara">
                                <?php echo $scara['name']->render(); ?>
                            </div>
                        <?php endforeach; ?>
                        <a class="add-scara" onclick="AddBlocuriForm.addScara(this)" title="adaugă o scară">+</a>
                    </td>
                </tr>
            <?php endforeach; ?>

            <?php if ($max_blocuri > count($form[EmptyBlocListForm::WRAPPER_NAME])): ?>
                <tr>
                    <td>
                        <a class="add-bloc" onclick="AddBlocuriForm.addBloc(this)" title="adaugă un bloc">+</a>
                    </td>
                    <td></td>
                </tr>
            <?php endif; ?>

        </tbody>

    </table>

    <div class="action">
        <input type="submit" value="Salvează" />
    </div>

</form>

<script type="text/javascript">
    Config.maxScara = <?php echo $max_scara ?>;
    Config.maxBlocuri = <?php echo $max_blocuri ?>;
    Config.scaraPerBloc = <?php echo $scara_per_bloc; ?>

    AddBlocuriForm.init('add-blocuri-form');
</script>

